public class t8_2 {
    public static void main(String[] args) {
        String s = "4193 with words";
        int sign = 1;
        int res = 0;
        s = s.trim();
        int m = s.length();
        for(int i =0; i < m; i++){
            char c = s.charAt(i);
            if(i==0 && c=='+'){
                sign = 1;
            }else if(i==0 && c=='-'){
                sign = -1;
            }else if(Character.isDigit(c)){
                int num = c-'0';
                if(res > Integer.MAX_VALUE/10 || (res == Integer.MAX_VALUE/10&&num>Integer.MAX_VALUE%10)){
                    //return Integer.MAX_VALUE;
                    System.out.println(Integer.MAX_VALUE);
                    break;
                }

                if(res < Integer.MIN_VALUE/10 || (res == Integer.MIN_VALUE/10&&-num<Integer.MIN_VALUE%10)){
                    //return Integer.MIN_VALUE;
                    System.out.println(Integer.MIN_VALUE);
                    break;
                }
                res = res*10+sign*num;
            }else{
                break;
            }
        }
        //return res;
        System.out.println(res);
    }
}


